##################################################################
# File : lua/sim/unitcommand.lua
# Description : Unitcommand lua module
# Author : GPG
##################################################################

#
# Command Types -- DO NOT MODIFY
#
UNITCOMMAND = {
    None                            = 0,
    Stop                            = 1,
    Move                            = 2,
    FormMove                        = 3,
    BuildFactory                    = 4,
    BuildMobile                     = 5,
    Attack                          = 6,
    FormAttack                      = 7,
    Guard                           = 8,
    Patrol                          = 9,
    FormPatrol                      = 10,
    Repair                          = 11,
    Capture                         = 12,
    Upgrade                         = 13,
    Script                          = 14,
    KillSelf                        = 15,
    DestroySelf                     = 16,
    Pause                           = 17,
    AggressiveMove                  = 18,
    FormAggressiveMove              = 19,
    SpecialAction                   = 20,
    NumCommandTypes                 = 21,
}

UnitCommand = Class(moho.unit_command_methods) {

    --[[
	Methods:
	    UNITCOMMAND GetType()
	
	     Command Units
	    list<unit> GetUnits()
	    bool ContainsUnit(unit)
	    bool HasFormation()
	
	    # Retrieve Attributes
	    bool AlwaysRepeatable(bool success)
	    bool FactoryRepeatable()
	    string GetId()
	    AITarget GetTarget()
	    vector3 GetPos()
	    vector3 GetRally()
	    vector2 GetLocation(unit)
	    quaternion GetOrientation()
	    table GetLuaObjectParam()
	
	    # Command Focus Unit Functions
	    unit CreateCommandFocusUnit(army, blueprint, location)
	    unit GetCommandFocusUnit()
	
	    # Set factory order info
	    nil SetIsFactoryOrder(bool flag)
	    bool GetIsFactoryOrder()
	
	    blueprint GetBlueprint()
	    list<vector2> GetCells()
	    int GetTotalCount()
	    int GetCurrentCount()
	    entity GetTargetEntity()
	    unit GetTargetUnit()
	
	    string GetTargetId()
	    vector3 GetTargetPosition()
	
	    int GetClock()
	
	    # Modify the command in place.
	    nil SetTarget(AITarget);
	
	    # Add or remove the given unit to this command and add or remove
	    # the command to the given command array.  By requiring both
	    # arguments, we can guarantee we don't screw up and only update
	    # one half of the linkage.  For add, position indicates where in
	    # the command array to insert the command -- negative numbers
	    # count from the end.
	    nil AddUnit(unit, list<UnitCommand>, int position = -1);
	    nil RemoveUnit(unit, list<UnitCommand>);
	
	    nil SetType(UNITCOMMAND)
	    nil SetCells(list<SOCellPos>)
	    nil SetTotalCount(int)
	    nil SetCurrentCount(int)
	
	    # Force the command to update next sync.
	    nil SetDirty()
	
	    # Coordinate this command with
	    nil CoordinateWith(UnitCommand);
	    nil SatisfiyCoordination()
	    bool IsCoordinating()
	    bool HasSatisfiedCoordination()
	    bool CheckForCoordinationSuccess()
	    list<UnitCommand> GetCoordinateWith()
	
	    # Flag that this command has been updated. Broadcast to all listners to this event.
	    nil CommandUpdated();
    --]]
}